** SELECT WORKING DIRECTORIES **
*global dir  "" // enter your working directory here
global dir "C:\Users\owner\Dropbox\Korea\Replication"  
global working "$dir\working"
global data "$dir\Data"
global output "$dir\Output"

cd "$data"

use "RegressiondataIO.dta", clear

*Set Output directory for tables and graphs

 cd "$output"


***************************************************
* MAIN TABLES
***************************************************

*Set control variables
global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

global controlsr2 c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year rain temp



* Table 1: Descriptives 
		est clear  
  estpost tabstat lagpm25 lagaqi yellowaqi redaqi air  environment  china rok usa presap natgov  INDEX_EC INDEX_LEC INDEX_FL INDEX_DE  INDEX_PH  ideology Female Age WP3117 INCOME_2, c(stat) stat(mean sd min max n)
ereturn list 

* Table 2: First stage regression 
  
  *IV regression
  * We are using the weakivtest developed here: https://www.stata-journal.com/article.html?article=st0377 based on  Montiel Olea and Pflueger (2013, Journal of Business and Economic Statistics 31: 358–369).
    * This article recommends this test doe cases that are heteroscedastic
	*If effective F is above 10 then typically t values are accurate
	*Estat endogenous reporst the Durban-Wu-Hausman test for the null hypothesis that air is exogenous.

   global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year
  est clear
  eststo f1: reg air lagaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagaqi   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f1
 estadd scalar criticalf=r(c_TSLS_10) :f1 
  
    eststo f2: reg air lagpm25 $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f2
 estadd scalar criticalf=r(c_TSLS_10) :f2 

   eststo f3: reg air lagaqi redaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagaqi redaqi  ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f3
 estadd scalar criticalf=r(c_TSLS_10) :f3 
  
    eststo f4: reg air lagpm25 redaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25 redaqi   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f4
 estadd scalar criticalf=r(c_TSLS_10) :f4 
  
    
    eststo f5: reg air lagpm25  i.REGION_KOR i.year, robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "No" 
   eststo: ivregress 2sls  china  i.REGION_KOR i.year  (air = lagaqi redaqi   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f5
 estadd scalar criticalf=r(c_TSLS_10) :f5 
  
    eststo f6: reg air lagpm25 redaqi i.REGION_KOR i.year, robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "No" 
   eststo: ivregress 2sls  china  i.REGION_KOR i.year  (air = lagpm25 redaqi   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f6
 estadd scalar criticalf=r(c_TSLS_10) :f6 
 
 
  esttab f1 f2 f3 f4 f5 f6 using "regressionstage1.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 keep (lagaqi lagpm25 redaqi  ) ///
 scalars( "N Obs." "R2 R2" "weakf Robust effective F" "criticalf Critical F value" "FE Region/Year FE" "CNTL Control Variables") sfmt(2) ///
 label booktabs nonotes noobs nomtitle collabels(none)  

 *Table 3: IV regression for air quality on leadership evaluation 
 
 est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


	foreach x of varlist environment china usa rok presap natgov {
 eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
 
   esttab menvironment mchina musa mrok mpresap mnatgov using "regression3.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 keep (air) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  scalars( "N Obs."   "FE Region/Year FE" "CNTL Control Variables") sfmt(2) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 

 *Table 4: Reduced Form Regression 
 
  global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


est clear
foreach x of varlist  environment  china usa rok presap natgov  {
 eststo: reg `x' lagpm25 $controls, robust cluster(REGION_KOR)
   testparm lagpm25 
   estadd scalar Fstat= r(F) 
   estadd scalar Pval = r(p)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
      
  esttab using "regressionITT.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 keep (lagpm25 ) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  scalars( "N Obs." "R2 R2"  "FE Region/Year FE" "CNTL Control Variables") sfmt(2) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1 1  1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

 *Table 5: Instrumental Variable Regressions of Perception of Air Quality with Subjective Evaluations of Economy, Daily Experiences, and Personal Health
 
 est clear
 
 
global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


foreach x of varlist  INDEX_EC INDEX_LEC INDEX_FL INDEX_DE  INDEX_PH   {
   eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25), robust cluster(REGION_KOR)
weakivtest
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
  
         
  esttab mINDEX_EC mINDEX_LEC mINDEX_FL mINDEX_DE  mINDEX_PH using "regressionIndex.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 keep (air) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  scalars( "N Obs."   "FE Region/Year FE" "CNTL Control Variables") sfmt(2) ///
 mgroups("Nat Econ" "Local Econ"  "Personal Econ" "Daily Experience" "Personal Health", pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})


***************************************************
* MAIN FIGURES
***************************************************


*Figure 1: outh Korean fine dust pollution compared to other OECD countries (Code Provided in a separate R file)

*Figure 2

cd "$data"

import excel using "petition_classification_IO.xlsx", firstrow clear
destring not_fine_dust any_blame_china domestic_solutions action_china num_agree, replace ignore(",")
keep if not_fine_dust==0 & num_agree>=25

cd "$output"

* Define both 
gen domestic_any  = (domestic_solutions==1)
gen domestic_only = (domestic_solutions==1 & action_china==0)
gen other_any  = 1 - domestic_any
gen other_only = 1 - domestic_only

*Graph 1*

preserve
    collapse (sum) domestic_any other_any domestic_only other_only, by(any_blame_china)
    label define blame_lbl 0 "Not Blame China" 1 "Blame China"
    label values any_blame_china blame_lbl

    * Graph A: ANY domestic action 
    graph bar domestic_any other_any, over(any_blame_china) stack ///
        ytitle("Number of Petitions") ///
        legend(order(1 "Any Domestic Action" 2 "Others")) ///
        title("Petition Types by Blame Attribution") ///
        blabel(bar, format(%9.0g) size(medsmall) position(center)) ///
        name(g_counts_any, replace)
    graph export "Petition_type.png", name(g_counts_any) replace width(2000)
restore 

*Graph 2*

preserve
    collapse (mean) mean=num_agree (count) N=num_agree (sd) sd=num_agree, by(any_blame_china)
    gen sem = sd/sqrt(N)
    gen lb  = mean - 1.96*sem
    gen ub  = mean + 1.96*sem

    label define blame_lbl 0 "Not Blame China" 1 "Blame China", replace
    label values any_blame_china blame_lbl

    twoway (bar mean any_blame_china, barwidth(0.5) color(navy%80)) ///
           (rcap lb ub any_blame_china, lcolor(black)), ///
        xlabel(0 1, valuelabel) ///
        xtitle("") ///
        ytitle("Mean Number of Signatures") legend(off) ///
        title("Mean Petition Signature by Blame China Attribution") ///
        graphregion(color(white)) yscale(noline) ///
        name(g_mean, replace)

    graph export "Petition_signature.png", name(g_mean) replace width(2000)
restore

* Figure 4: Variation in Air Quality Index within Survey Periods by Region

cd "$data"

use "RegressiondataIO.dta", clear

cd "$output"


preserve
    keep if (REGION_KOR < 5 | REGION_KOR == 8 | REGION_KOR == 15)
    collapse (mean) aqi, by(WP4 REGION_KOR)
    gen year = year(WP4)
    drop if year < 2015
    replace REGION_KOR = . if REGION_KOR > 16
    graph box aqi, over(year, label(angle(forty_five) labsize(small) labgap(4))) by(REGION_KOR)
    graph export "Figure1.png", as(png) replace
restore

  
***************************************************
* APPENDIX TABLES 
***************************************************
 
cd "$data"

use "RegressiondataIO.dta", clear

cd "$output"

 
*Table 1: Manuscript Table 2

   global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year
  est clear
  eststo f1: reg air lagaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagaqi   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f1
 estadd scalar criticalf=r(c_TSLS_10) :f1 
  
    eststo f2: reg air lagpm25 $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f2
 estadd scalar criticalf=r(c_TSLS_10) :f2 

   eststo f3: reg air lagaqi redaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagaqi redaqi  ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f3
 estadd scalar criticalf=r(c_TSLS_10) :f3 
  
    eststo f4: reg air lagpm25 redaqi $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25 redaqi ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f4
 estadd scalar criticalf=r(c_TSLS_10) :f4 

    eststo f5: reg air lagpm25  i.REGION_KOR i.year, robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "No" 
   eststo: ivregress 2sls  china  i.REGION_KOR i.year  (air = lagaqi redaqi), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f5
 estadd scalar criticalf=r(c_TSLS_10) :f5 
  
    eststo f6: reg air lagpm25 redaqi i.REGION_KOR i.year, robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "No" 
   eststo: ivregress 2sls  china  i.REGION_KOR i.year  (air = lagpm25 redaqi), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f6
 estadd scalar criticalf=r(c_TSLS_10) :f6 

    esttab f1 f2 f3 f4 f5 f6 using "regressionstage1app.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
  nobaselevels noomitted /// 
 drop(*REGION_KOR *.year) ///
     coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
 scalars( "N Obs." "R2 R2" "weakf Robust effective F" "criticalf Critical F value" "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 label booktabs nonotes noobs nomtitle collabels(none)  


*Table 2: Manuscript Table 3

 est clear
	
   global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


	foreach x of varlist environment china usa rok presap natgov {
 eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }

   esttab menvironment mchina musa mrok mpresap mnatgov using "regression3app.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
  drop(*REGION_KOR *.year) ///
      coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})



*Table 3: Manuscript Table 4


 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


est clear
foreach x of varlist  environment  china rok usa presap natgov  {
 eststo: reg `x' lagpm25 $controls, robust cluster(REGION_KOR)
   testparm lagpm25 
   estadd scalar Fstat= r(F) 
   estadd scalar Pval = r(p)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
      

   esttab using "regressionITTapp.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
  drop(*REGION_KOR *.year) ///
      coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "R2 R2" "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China"  "ROK" "USA" "President" "Gvt Confidence" , pattern(1 1  1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})



*Table 4: Manuscript Table 5 

 est clear
   
   global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

foreach x of varlist  INDEX_EC INDEX_LEC INDEX_FL INDEX_DE  INDEX_PH   {
   eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25), robust cluster(REGION_KOR)
weakivtest
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
 
esttab mINDEX_EC mINDEX_LEC mINDEX_FL mINDEX_DE mINDEX_PH using "regressionIndexapp.tex", replace ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
   label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
    drop(*.REGION_KOR *.year) ///
	    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
	scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
    mgroups("Nat Econ" "Local Econ" "Personal Econ" "Daily Experience" "Personal Health", ///
            pattern(1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
    alignment(D{.}{.}{-1})
  
*Table 5: OLS Regression with Controls   
 
  	est clear

	 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': reg `x' air $controls , robust cluster(REGION_KOR)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
  }

   esttab menvironment mchina musa mrok mpresap mnatgov using "regressionOLSapp.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
 drop(*REGION_KOR *.year) ///
     coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "R2 R2" "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
  
 
*Table 6: Including Daily Regional Temperature and Precipitation (Logged) 

 est clear

global controlsr2 c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year rain temp
	
	
	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controlsr2 (air = lagpm25 ) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
      
  esttab menvironment mchina musa mrok mpresap mnatgov using "regression3temp.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 
 *Table 7: Month and Day Fixed Effects 
 
 est clear

 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controls i.dayofweek i.month (air = lagpm25), robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
      
  esttab menvironment mchina musa mrok mpresap mnatgov using "regression3month.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
   drop(*.REGION_KOR *.year *.dayofweek *.month) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year/Day/Month FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 
 
*Table 8: Excluding Covid peak year in South Korea 

 est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25) if covid == 0, robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
 
   esttab menvironment mchina musa mrok mpresap mnatgov using "regressioncovid.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
    drop(*.REGION_KOR *.year) ///
	    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

 
 *Table 9: including Regional Coal Plant Electricity Production (Logged, KW) 

 est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controls ln_kw_plant (air = lagpm25), robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
 
   esttab menvironment mchina musa mrok mpresap mnatgov using "regressionkw.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
    drop(*.REGION_KOR *.year) ///
	    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

*Table 10: Including Number of Daily Media on China 

  est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	foreach x of varlist china usa rok presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controls chn_media_count (air = lagpm25), robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
 
   esttab menvironment mchina musa mrok mpresap mnatgov using "regressionmedia.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
  label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
    drop(*.REGION_KOR *.year) ///
	    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

 
*Table 11:Two-Stage Least Squares(2SLS) Evaluating Link between Confidence in the Local Economy and Approval of Chinese Leadership 
 
 est clear
 

 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


	foreach x of varlist environment china usa rok presap natgov {
 eststo m`x': ivregress 2sls  `x'  $controls (INDEX_LEC = lagpm25), robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
      
 esttab menvironment mchina musa mrok mpresap mnatgov using "regressionIVINDEXapp.tex", replace ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
    drop(*.REGION_KOR *.year) ///
	    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
    stats(N r2 FE CNTL weakf criticalf, ///
          labels("Obs." "Region/Year FE" "Control Variables" "Weak IV F-stat" "10% Critical F") ///
          fmt(0 0 0 0 0 0)) ///
    mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence", ///
            pattern(1 1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
    alignment(D{.}{.}{-1})

 *Table 12 :Analyses Differentiating between Pollution Originating from China and Local Sources
 
gen R2 = .
forvalues i = 1/16 {
   capture quietly reg lagpm25 lagpm25Ganghwa i.year if REGION_KOR==`i', vce(cluster REGION_KOR)
   replace R2 = e(r2_a) if REGION_KOR==`i'   
}

est clear

 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


foreach x of varlist  environment  china usa rok presap natgov  {
 eststo: reg `x' c.lagpm25##c.R2  $controls, vce(cluster REGION_KOR)
   testparm lagpm25 
   estadd scalar Fstat= r(F) 
   estadd scalar Pval = r(p)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
      

   esttab using "regressionRchina.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "R2 R2"  "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA"  "ROK" "President" "Gvt Confidence" , pattern(1 1  1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})


*Table 13: First stage regressions using Gangwha pm2.5 and the estimated local and Chinese sources of pollution

*label variable lagpmChina "AQI, pm2.5, estimated from Chinese sources"

egen grp = group(REGION_KOR)
levelsof grp, local(g)
gen r2 = .
gen b=.
foreach x of local g{
qui reg lagpm25 lagpm25Ganghwa  $controls i.year if grp==`x', robust
   replace r2 = e(r2_a) if grp==`x'
   replace b =  _b[lagpm25Ganghwa] if grp==`x'
}

gen lagpmChina=b*lagpm25Ganghwa

est clear

   global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

  eststo f2: reg air lagpm25Ganghwa $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25Ganghwa   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f2
 estadd scalar criticalf=r(c_TSLS_10) :f2 
  
    eststo f1: reg air lagpm25 lagpm25Ganghwa  $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpm25 lagpm25Ganghwa  ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f1
 estadd scalar criticalf=r(c_TSLS_10) :f1 

  
    eststo f3: reg air lagpmChina $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls   (air = lagpmChina   ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f3
 estadd scalar criticalf=r(c_TSLS_10) :f3 
  
   
    eststo f4: reg air lagpm25 lagpmChina $controls , robust cluster(REGION_KOR)
  estadd scalar R2 = e(r2)
      estadd local FE  "Yes"
  estadd local CNTL "Yes" 
   eststo: ivregress 2sls  china  $controls (air = lagpm25 lagpmChina  ), robust cluster(REGION_KOR)
   weakivtest
 estadd scalar weakf=r(F_eff) : f4
 estadd scalar criticalf=r(c_TSLS_10) :f4 

 esttab f1 f2 f3 f4 using "regressionstage1Ganghwaapp.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
 scalars( "N Obs." "R2 R2" "weakf Robust effective F" "criticalf Critical F value" "FE Region/Year FE" "CNTL Control Variables") sfmt(0)  

*Table 14: Reduced Form Regressions of Estimated Chinese and Locally Sourced Air Pollution on Political Evaluations 

est clear

global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

foreach x of varlist  environment  china usa rok presap natgov  {
 eststo: reg `x' lagpm25 lagpmChina $controls, robust cluster(REGION_KOR)
   testparm lagpm25 lagpmChina
   estadd scalar Fstat= r(F) 
   estadd scalar Pval = r(p)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
      
   esttab using "regressionITTChinaLocalapp.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
  nobaselevels noomitted /// 
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs." "R2 R2"  "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China"  "USA" "ROK" "President" "Gvt Confidence" , pattern(1 1  1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

 * Table 15 : IV estimates (Wind Direction X Region)
 
 est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	
	foreach x of varlist environment china usa rok presap natgov {
 eststo m`x': ivregress 2sls  `x'  $controls (lagpm25 = i.Compass##i.REGION_KOR i.month) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }

  
esttab menvironment mchina musa mrok mpresap mnatgov using "regressionWinddirection.tex", replace ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    label booktabs nonotes noobs nomtitle collabels(none) ///
    nobaselevels noomitted ///
    drop(*.REGION_KOR *.year _cons) ///
    coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
	  scalars( "N Obs." "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
    mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence", ///
            pattern(1 1 1 1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
    alignment(D{.}{.}{-1})

* Table 16 : IV estimates (Wind Direction X Speed X Region)
 
est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	
	foreach x of varlist environment china usa rok presap natgov {
 eststo m`x': ivregress 2sls  `x'  $controls (lagpm25 = i.Compass##i.REGION_KOR##c.WindSpeed i.month) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }

  
   esttab menvironment mchina musa mrok mpresap mnatgov using "regressionWindSpeed.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
 nobaselevels noomitted ///
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs."   "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 
*Table 17 : Equivalence Table 

global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year
global delta 0.07

// Define different confidence levels to test
local confidence_levels "80 85 90 95 99"

foreach x of varlist china rok usa presap natgov environment {
    display "=== Equivalence tests for `x' at different confidence levels ==="
    
    // Run the regression once
    reg `x' lagpm25 $controls, robust cluster(REGION_KOR)
    
    // Get coefficient and standard error
    matrix b = e(b)
    matrix V = e(V)
    local coeff = b[1,1]
    local se = sqrt(V[1,1])
    
    foreach conf of local confidence_levels {
        local alpha = (100 - `conf')/100
        local z_crit = invnormal(1 - `alpha'/2)
        
        // Calculate confidence interval
        local ci_lower = `coeff' - `z_crit' * `se'
        local ci_upper = `coeff' + `z_crit' * `se'
        
        // Check if CI falls within equivalence bounds
        if `ci_lower' > -$delta & `ci_upper' < $delta {
            local equiv_status = "YES"
        }
        else {
            local equiv_status = "NO"
        }
        
        display "`conf'% CI: [`ci_lower', `ci_upper'] - Equivalent to zero: `equiv_status'"
    }
    display "---"
}  
    
*Table 18: Russia, Germany and Japan as Placebo

est clear
	
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

	foreach x of varlist russia WP153 japan china usa rok {
 eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25) , robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }

   esttab mrussia mWP153 mjapan mchina musa mrok  using "regressionRussiaJapan.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
 nobaselevels noomitted ///
   drop(*.REGION_KOR *.year) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs."   "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Russia" "Germany" "Japan" "China" "USA" "ROK"  , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 

*Table 19 : Mediation Analyses 

 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year

 ivmediate china  $controls, mediator(INDEX_LEC) treatment(air) instrument (lagpm25) absorb(REGION_KOR) vce (cluster REGION_KOR)
  

*Table 20: Rescaled 


xtile ec4q = INDEX_EC, nq(4)
xtile lec4q = INDEX_LEC, nq(4)

* labeling
label define lec4qlbl 1 "Q1" 2 "Q2" 3 "Q3" 4 "Q4"
label values lec4q lec4qlbl
label define ec4qlbl 1 "Q1" 2 "Q2" 3 "Q3" 4 "Q4"
label values ec4q ec4qlbl

 est clear
   
 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year


foreach x of varlist  ec4q lec4q INDEX_FL INDEX_DE  INDEX_PH   {
   eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25), robust cluster(REGION_KOR)
weakivtest
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
estadd scalar R2 = e(r2)

  
 }
         
  esttab mec4q mlec4q mINDEX_FL mINDEX_DE  mINDEX_PH using "regressionIndexscale.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
 nobaselevels noomitted ///
  drop(*.REGION_KOR *.year) ///
      coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs."   "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Nat Econ" "Local Econ"  "Personal Econ" "Daily Experience" "Personal Health", pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})
 

*Table 21: Left Right Differences  

 global controls c.ideology##left i.Female Age i.WP3117 INCOME_2 i.REGION_KOR i.year 


est clear

	foreach x of varlist china usa rok japan presap natgov environment {
 eststo m`x': ivregress 2sls  `x'  $controls (air = lagpm25) i.air##i.left, robust cluster(REGION_KOR)
 quietly: weakivtest
 estadd scalar weakf=r(F_eff)
 estadd scalar criticalf=r(c_TSLS_10)
  estadd local FE  "Yes"
  estadd local CNTL "Yes"
 

 }
      
  esttab menvironment mchina musa mrok mpresap mnatgov using "regressionleft.tex", replace   ///
 b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
 label booktabs nonotes noobs nomtitle collabels(none)  ///
 nobaselevels noomitted /// 	
   keep (*air *left) ///
       coeflabels( ///
        1.left            "left" ///
        1.left#c.ideology "left × Ideology" ///
        c.ideology#1.left "left × Ideology" ///
    ) ///
  scalars( "N Obs."  "FE Region/Year FE" "CNTL Control Variables") sfmt(0) ///
 mgroups("Gvt Environment" "China" "USA" "ROK" "President" "Gvt Confidence" , pattern(1  1 1 1 1 1) ///
 prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) alignment(D{.}{.}{-1})

*Figure 1

cd "$data"
use "MediaYearly.dta", clear

keep if Year >= 1995 & Year <2023

twoway bar Count Year, ///
    barwidth(0.9) ///
    xlabel(1995(5)2020, grid glpattern(dot) glcolor(gs12)) ///  <-- labels only at 5-year marks
    xtitle("Year") ytitle("Number of Articles") ///
    graphregion(color(white)) plotregion(color(white))
	
graph export "microdustbigkind.png", as(png) replace
